home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 22 / PC Actual CD 22.iso / progs / Netobj / netobj / t2.z / BBSComp.nfx (.txt) < prev    next >
Encoding:
Java Class File  |  1997-04-29  |  8.9 KB  |  264 lines

  1. public class BBSComp extends ComponentApp {
  2.    DAssetManager cam;
  3.    DDrawPicture cdp;
  4.    int idScript;
  5.    String Subdirectory;
  6.    String Title;
  7.    String UnixWindows;
  8.    String PerlPath;
  9.    boolean AdminTool;
  10.    String codeBase;
  11.    static int onlyYou;
  12.    int onlyYouInvalid;
  13.    static final int MAXASSET = 50;
  14.    boolean published;
  15.    int[] assetControl;
  16.    int assetCount;
  17.    int tAssetCount;
  18.  
  19.    public String PropertyListener(String var1, String var2, int var3, int var4, IDInspector var5) {
  20.       if (var3 == 1) {
  21.          if (var1.compareTo("Subdirectory") == 0) {
  22.             return this.Subdirectory;
  23.          }
  24.  
  25.          if (var1.compareTo("Page Title") == 0) {
  26.             return this.Title;
  27.          }
  28.  
  29.          if (var1.compareTo("Publish to") == 0) {
  30.             if (this.UnixWindows.compareTo("Windows") == 0) {
  31.                return "0";
  32.             }
  33.  
  34.             if (this.UnixWindows.compareTo("Unix") == 0) {
  35.                return "1";
  36.             }
  37.          } else if (var1.compareTo("Perl Path for Unix") == 0) {
  38.             return this.PerlPath;
  39.          }
  40.       } else {
  41.          if (var1.compareTo("Subdirectory") == 0) {
  42.             this.Subdirectory = var2;
  43.          } else if (var1.compareTo("Page Title") == 0) {
  44.             this.Title = var2;
  45.          } else if (var1.compareTo("Publish to") == 0) {
  46.             if (var2.compareTo("0") == 0) {
  47.                this.UnixWindows = "Windows";
  48.             } else if (var2.compareTo("1") == 0) {
  49.                this.UnixWindows = "Unix";
  50.             }
  51.          } else if (var1.compareTo("Perl Path for Unix") == 0) {
  52.             this.PerlPath = var2;
  53.          }
  54.  
  55.          this.cdp.setHTMLBefore("<a href=\"#\" target=_self onclick='launchBBS(\"" + this.Subdirectory + "\",\"" + this.Title + "\")'>");
  56.          this.cdp.setHTMLAfter("</a>");
  57.       }
  58.  
  59.       return "";
  60.    }
  61.  
  62.    public void onCopy() {
  63.       this.Subdirectory = new String(this.Subdirectory);
  64.       this.Title = new String(this.Title);
  65.       this.PerlPath = new String(this.PerlPath);
  66.       this.codeBase = new String(this.codeBase);
  67.       this.cam.CopyAsset(this.idScript);
  68.       int[] var1 = new int[50];
  69.  
  70.       for(this.tAssetCount = 0; this.tAssetCount < this.assetCount; ++this.tAssetCount) {
  71.          this.cam.CopyAsset(this.assetControl[this.tAssetCount]);
  72.          var1[this.tAssetCount] = this.assetControl[this.tAssetCount];
  73.       }
  74.  
  75.       this.assetControl = var1;
  76.    }
  77.  
  78.    private String getJavaScript() {
  79.       return "function newCookie(name, value){\n  document.cookie = name + \"=\" + value +  \"; path=/; domain=\" + location.hostname + \";\";     \n}\nfunction launchBBS(URL,Title){\n      var direct = location.pathname; \n   if((location.pathname.lastIndexOf(\"/\") + 1) == location.pathname.length){\t\n\t  direct = location.pathname;\t \n\t    }\t   \n      else{\t\n      direct = location.pathname.substring(0,location.pathname.lastIndexOf(\"/\")) + \"/\";\t \n\t }\n if (direct.substring(direct.length - 5, direct.length - 1) == \"html\"){\n   direct = direct.substring(0, direct.length - 6) + \"/\";\n } \n" + "if (location.port.length == 0){\n\tNURL= location.protocol+\"//\" + location.hostname + direct  + URL + \"/\";\n }\n\t else {\n NURL= location.protocol+\"//\" + location.hostname + \":\" + location.port + direct  + URL + \"/\";\n\t} \n var WinName = window.open(NURL+'index.html','netobjects_bbs','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,copyhistory=0,width=800,height=600');\n if (navigator.appVersion.indexOf(\"(X11\") != -1 ||\n        navigator.appVersion.indexOf(\"(Mac\") != -1)\n      newWin = window.open(NURL+'index.html','netobjects_bbs');\nnewCookie(\"URL\",NURL);\nnewCookie(\"Title\",Title);\nnewCookie(\"CgiURL\",NURL+\"cgi-bin\");\nnewCookie(\"GifURL\",NURL+\"image/webforum.gif\");\n} \n";
  80.    }
  81.  
  82.    public String onInstall(DAssetManager var1, String var2) {
  83.       this.cam = var1;
  84.       this.codeBase = var2;
  85.       return "BBS";
  86.    }
  87.  
  88.    protected void finalize() {
  89.       this.cam.RemoveAsset(this.idScript);
  90.       if (this.published) {
  91.          for(this.assetCount = 0; this.assetCount < 50; ++this.assetCount) {
  92.             this.cam.RemoveAsset(this.assetControl[this.assetCount]);
  93.          }
  94.       }
  95.  
  96.       if (this.onlyYouInvalid == 0) {
  97.          onlyYou = 0;
  98.       }
  99.  
  100.    }
  101.  
  102.    public void onPublish(DAssetManager var1, int var2) {
  103.       this.cdp.setHTMLBefore("<a href=\"#\" target=_self onclick='launchBBS(\"" + this.Subdirectory + "\",\"" + this.Title + "\")'>");
  104.       this.cdp.setHTMLAfter("</a>");
  105.       String var3 = this.codeBase;
  106.       if (this.published) {
  107.          for(this.assetCount = 0; this.assetCount < 50; ++this.assetCount) {
  108.             this.cam.RemoveAsset(this.assetControl[this.assetCount]);
  109.          }
  110.       }
  111.  
  112.       this.assetCount = 0;
  113.       this.published = true;
  114.       this.assetControl[this.assetCount] = this.cam.AddAsset(var3 + "bbs\\bbs-control.html", "HTML\u0000", this.Subdirectory);
  115.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\bbs-message.html", "HTML\u0000", this.Subdirectory);
  116.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\blank.html", "HTML\u0000", this.Subdirectory);
  117.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\index.html", "HTML\u0000", this.Subdirectory);
  118.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\image\\dot24_clear.gif", "Image\u0000", this.Subdirectory + "\\image");
  119.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\image\\background.gif", "Image\u0000", this.Subdirectory + "\\image");
  120.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\image\\clear.gif", "Image\u0000", this.Subdirectory + "\\image");
  121.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\image\\expand.gif", "Image\u0000", this.Subdirectory + "\\image");
  122.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\image\\listby.gif", "Image\u0000", this.Subdirectory + "\\image");
  123.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\image\\newmessage.gif", "Image\u0000", this.Subdirectory + "\\image");
  124.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\image\\next.gif", "Image\u0000", this.Subdirectory + "\\image");
  125.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\image\\previous.gif", "Image\u0000", this.Subdirectory + "\\image");
  126.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\image\\reload.gif", "Image\u0000", this.Subdirectory + "\\image");
  127.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\image\\reply.gif", "Image\u0000", this.Subdirectory + "\\image");
  128.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\html\\error-char.html", "HTML\u0000", this.Subdirectory + "\\html");
  129.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\html\\error.html", "HTML\u0000", this.Subdirectory + "\\html");
  130.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\html\\success.html", "HTML\u0000", this.Subdirectory + "\\html");
  131.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\html\\url-only-char.html", "HTML\u0000", this.Subdirectory + "\\html");
  132.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\html\\urlreply.html", "HTML\u0000", this.Subdirectory + "\\html");
  133.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\message\\bbs-data.original", "HTML\u0000", this.Subdirectory + "\\message");
  134.       this.cam.SetPublishAssetMode(this.assetControl[this.assetCount], 452);
  135.       this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\message\\zero.counter", "HTML\u0000", this.Subdirectory + "\\message");
  136.       this.cam.SetPublishAssetMode(this.assetControl[this.assetCount], 452);
  137.       this.assetControl[++this.assetCount] = this.cam.AddAsset(this.Subdirectory + "\\message\\", "SubDir\u0000", "");
  138.       this.cam.SetPublishAssetMode(this.assetControl[this.assetCount], 455);
  139.       if (this.UnixWindows.compareTo("Windows") == 0) {
  140.          this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\cgi-bin-NT\\bbs-submit.cgi", "CGI\u0000", this.Subdirectory + "\\cgi-bin");
  141.          this.cam.SetPublishAssetMode(this.assetControl[this.assetCount], 453);
  142.          this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\cgi-bin-NT\\submit-bbs-form.cgi", "CGI\u0000", this.Subdirectory + "\\cgi-bin");
  143.          this.cam.SetPublishAssetMode(this.assetControl[this.assetCount], 453);
  144.          this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\cgi-bin-NT\\Buf.dll", "CGI\u0000", this.Subdirectory + "\\cgi-bin");
  145.          this.cam.SetPublishAssetMode(this.assetControl[this.assetCount], 453);
  146.       } else if (this.UnixWindows.compareTo("Unix") == 0) {
  147.          DFile var4 = new DFile();
  148.          DFile var5 = new DFile();
  149.          var5.Open(var3 + "bbs\\cgi-bin-Unix\\config", 0);
  150.          var4.Open(var3 + "bbs\\cgi-bin\\config", 4097);
  151.          var4.WriteString("#!" + this.PerlPath + "\n", -1);
  152.          var4.WriteString(var5.ReadString(10000), -1);
  153.          var4.Close();
  154.          var5.Close();
  155.          var5.Open(var3 + "bbs\\cgi-bin-Unix\\submit-bbs-form.cgi", 0);
  156.          var4.Open(var3 + "bbs\\cgi-bin\\submit-bbs-form.cgi", 4097);
  157.          var4.WriteString("#!" + this.PerlPath + "\n\n", -1);
  158.          var4.WriteString(var5.ReadString(20000), -1);
  159.          var4.Close();
  160.          var5.Close();
  161.          var5.Open(var3 + "bbs\\cgi-bin-Unix\\bbs-submit.cgi", 0);
  162.          var4.Open(var3 + "bbs\\cgi-bin\\bbs-submit.cgi", 4097);
  163.          var4.WriteString("#!" + this.PerlPath + "\n", -1);
  164.          var4.WriteString(var5.ReadString(20000), -1);
  165.          var4.Close();
  166.          var5.Close();
  167.          this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\cgi-bin\\bbs-submit.cgi", "CGI\u0000", this.Subdirectory + "\\cgi-bin");
  168.          this.cam.SetPublishAssetMode(this.assetControl[this.assetCount], 453);
  169.          this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\cgi-bin\\config", "CGI\u0000", this.Subdirectory + "\\cgi-bin");
  170.          this.cam.SetPublishAssetMode(this.assetControl[this.assetCount], 453);
  171.          this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\cgi-bin\\submit-bbs-form.cgi", "CGI\u0000", this.Subdirectory + "\\cgi-bin");
  172.          this.cam.SetPublishAssetMode(this.assetControl[this.assetCount], 453);
  173.          if (!this.AdminTool) {
  174.             var5.Open(var3 + "bbs\\admin-bin-Unix\\deleteMessage.cgi", 0);
  175.             var4.Open(var3 + "bbs\\admin-bin\\deleteMessage.cgi", 4097);
  176.             var4.WriteString("#!" + this.PerlPath + "\n", -1);
  177.             var4.WriteString(var5.ReadString(10000), -1);
  178.             var4.Close();
  179.             var5.Close();
  180.             var5.Open(var3 + "bbs\\admin-bin-Unix\\resetBBS.cgi", 0);
  181.             var4.Open(var3 + "bbs\\admin-bin\\resetBBS.cgi", 4097);
  182.             var4.WriteString("#!" + this.PerlPath + "\n\n", -1);
  183.             var4.WriteString(var5.ReadString(20000), -1);
  184.             var4.Close();
  185.             var5.Close();
  186.             this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\admin-bin\\deleteMessage.cgi", "CGI\u0000", this.Subdirectory + "\\admin-bin");
  187.             this.cam.SetPublishAssetMode(this.assetControl[this.assetCount], 453);
  188.             this.assetControl[++this.assetCount] = this.cam.AddAsset(var3 + "bbs\\admin-bin\\resetBBS.cgi", "CGI\u0000", this.Subdirectory + "\\admin-bin");
  189.             this.cam.SetPublishAssetMode(this.assetControl[this.assetCount], 453);
  190.          }
  191.       }
  192.  
  193.    }
  194.  
  195.    void OnDropOK() {
  196.       this.cam.InsertScript("bbs_script_layout", this.getJavaScript());
  197.       onlyYou = 1;
  198.    }
  199.  
  200.    public void onDrop(IDLayout var1, IDRect var2, int var3) {
  201.       if (var3 == 1) {
  202.          if (this.CheckTwoInstancesError()) {
  203.             return;
  204.          }
  205.  
  206.          this.assetControl = new int[50];
  207.          int var4 = 0;
  208.  
  209.          do {
  210.             this.assetControl[var4] = 0;
  211.             ++var4;
  212.          } while(var4 < 50);
  213.  
  214.          String var8 = this.codeBase;
  215.          this.Subdirectory = "bbs";
  216.          this.Title = "NetObjects BBS";
  217.          this.UnixWindows = "Windows";
  218.          this.AdminTool = true;
  219.          this.PerlPath = "/usr/local/bin/perl";
  220.          this.cdp = new DDrawPicture();
  221.          DImage var5 = new DImage();
  222.          var5.setImageFile(var8 + "bbs\\image\\BBSComp.gif");
  223.          IDSize var6 = var5.getSize();
  224.          this.cdp.setImageFile(var8 + "bbs\\image\\BBSComp.gif");
  225.          this.cdp.SetPositionRect(var2.getLeft(), var2.getTop(), var2.getLeft() + var6.getWidth(), var2.getTop() + var6.getHeight());
  226.          this.cdp.setStretch(1);
  227.          this.idScript = this.cam.AddAsset("bbs_script_layout", "Java Script\u0000", "");
  228.          var1.AddObject(this.cdp);
  229.          this.OnDropOK();
  230.       } else if (var3 == 3) {
  231.          if (this.CheckTwoInstancesError()) {
  232.             return;
  233.          }
  234.  
  235.          this.OnDropOK();
  236.       }
  237.  
  238.    }
  239.  
  240.    public void onInspect(CStringArray var1, CStringArray var2) {
  241.       if (this.onlyYouInvalid != 1) {
  242.          var1.Set("Subdirectory");
  243.          var2.Set("String\u0000");
  244.          var1.Set("Page Title");
  245.          var2.Set("String\u0000");
  246.          var1.Set("Publish to");
  247.          var2.Set("Set(Windows|Unix)");
  248.          var1.Set("Perl Path for Unix");
  249.          var2.Set("String\u0000");
  250.       }
  251.    }
  252.  
  253.    boolean CheckTwoInstancesError() {
  254.       if (onlyYou == 1) {
  255.          DMessageBox var1 = new DMessageBox();
  256.          var1.Warnning("Only one BBS Component is allowed per NOD file. Please delete the extra BBS Components.");
  257.          this.onlyYouInvalid = 1;
  258.          return true;
  259.       } else {
  260.          return false;
  261.       }
  262.    }
  263. }
  264.